package com.example.service.impl;

import com.example.mapper.PositionMapper;
import com.example.pojo.Position;
import com.example.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * Created by sang on 2018/1/10.
 */
@Service
@Transactional
public class PositionServiceImpl implements IPositionService {
    @Autowired
    private PositionMapper positionMapper;

    @Override
    public int addPos(Position pos) {
        if (positionMapper.getPosByName(pos.getName()) != null) {
            return -1;
        }
        return positionMapper.addPos(pos);
    }
    @Override
    public List<Position> getAllPos() {

        return positionMapper.getAllPos();
    }

    @Override
    public boolean deletePosById(String pids) {
        String[] split = pids.split(",");
        return positionMapper.deletePosById(split) == split.length;
    }

    @Override
    public int updatePosById(Position position) {

        return positionMapper.updatePosById(position);
    }

}
